<?php

/**
 * 品牌活动的basic
 */
ini_set('display_errors', 1);
error_reporting(-1);
require_once '/data/wwwroot/g_vendor/autoload.php';

use Biz\model\brandActivity\BlindBoxActivity;
use Biz\model\brandActivity\BrandActivityBasic;
use Biz\model\GoodsTestActivity\FineGoodsModel;
use Biz\model\NewProduct\NewProductWikiModel;


$now = time();
$where = [
    'activity_state' => BlindBoxActivity::ACTIVITY_STATE_PASS
];
$blindBoxList = BlindBoxActivity::selectByWhere($where, '*');
foreach ($blindBoxList as $row) {
    BrandActivityBasic::updateActivityBasic($row['id'], BrandActivityBasic::ACTIVITY_TYPE_BLIND_BOX, $row['brand_id'], $row['basic_id'], $row['start_time'], $row['end_time']);
    var_dump(BrandActivityBasic::log());
}

$where = [
    'basic_id[>]' => 0,
    'status' => NewProductWikiModel::STATUS_NORMAL,
    'is_delete' => 0,
];

$newProductList = NewProductWikiModel::all($where, '*');
foreach ($newProductList as $row) {
    BrandActivityBasic::updateActivityBasic($row['id'], BrandActivityBasic::ACTIVITY_TYPE_NEW_PRODUCT, $row['brand_id'], $row['basic_id'], strtotime($row['start_time']), strtotime($row['end_time']));
    var_dump(BrandActivityBasic::log());
}

$where = [
    'activity_state' => FineGoodsModel::STATE_PASS,
];
$fineGoodsList = FineGoodsModel::all($where, '*');
foreach ($fineGoodsList as $row) {
    BrandActivityBasic::updateActivityBasic($row['id'], BrandActivityBasic::ACTIVITY_TYPE_LIGHT_TEST, $row['brand_id'], $row['basic_id'], $row['schedule_start_time'], $row['schedule_end_time']);
    var_dump(BrandActivityBasic::log());
}
